package com.ruoyi.products.service.impl;

import java.util.List;

import com.ruoyi.purchase.domain.Purchase;
import com.ruoyi.sale.domain.Sale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.products.mapper.ProductsMapper;
import com.ruoyi.products.domain.Products;
import com.ruoyi.products.service.IProductsService;

/**
 * 产品功能Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-09-24
 */
@Service
public class ProductsServiceImpl implements IProductsService 
{
    @Autowired
    private ProductsMapper productsMapper;

    /**
     * 查询产品功能
     * 
     * @param id 产品功能主键
     * @return 产品功能
     */
    @Override
    public Products selectProductsById(Integer id)
    {
        return productsMapper.selectProductsById(id);
    }

    /**
     * 查询产品功能列表
     * 
     * @param products 产品功能
     * @return 产品功能
     */
    @Override
    public List<Products> selectProductsList(Products products)
    {
        return productsMapper.selectProductsList(products);
    }

    /**
     * 新增产品功能
     * 
     * @param products 产品功能
     * @return 结果
     */
    @Override
    public int insertProducts(Products products)
    {
        return productsMapper.insertProducts(products);
    }

    /**
     * 修改产品功能
     * 
     * @param products 产品功能
     * @return 结果
     */
    @Override
    public int updateProducts(Products products)
    {
        return productsMapper.updateProducts(products);
    }

    /**
     * 批量删除产品功能
     * 
     * @param ids 需要删除的产品功能主键
     * @return 结果
     */
    @Override
    public int deleteProductsByIds(Integer[] ids)
    {
        return productsMapper.deleteProductsByIds(ids);
    }

    /**
     * 删除产品功能信息
     * 
     * @param id 产品功能主键
     * @return 结果
     */
    @Override
    public int deleteProductsById(Integer id)
    {
        return productsMapper.deleteProductsById(id);
    }

    @Override
    public void reducePorduct(Sale sale) {
        productsMapper.reduceProductQu(sale);
    }

    @Override
    public Integer selIdByPN(String productName) {
       return  productsMapper.selectProductIdByName(productName);
    }

    @Override
    public void increaseProductQu(Purchase purchase) {
     productsMapper.increaseProductQu(purchase);
    }
}
